CapToMusic (Version 1.41, 11/06/17) by Bernd Jungmann

This script translates a capella file into a MusicXML file, which can be 
imported in Finale or Sibelius or others.

CapToMusic.zip contains also the three support files Rtf2TxtAndFont.py, 
Rtf2Txt.py, and RtfParser.py by Loic Fejoz 
(http://sourceforge.net/projects/pyrtflib), the first is modified by me.
Also contained is the script SetupC2M.py by me, which implements a persistence
mechanism for variables like globalExportToSibelius.

For capella versions up to 5.2, all 5 files are to be unpacked into the 
capella scripts directory.

For capella versions starting at 5.3, if CapToMusic shall update the MusicXML 
export File - Export - MusicXML, unpack destination is subdirectory 
data\CapToMusic.

If CapToMusic is to be used from capella-scan, all 5 Python files have
to be in the capella-scan directory, where capscan.exe is located.

If you start this script from capella, it will translate the active score.
You can also start Python with this script from the commandline:

python CapToMusic.py -l# -f FilenameWithoutExtension -o DestFile

If DestFile is not given, FilenameWithoutExtension is taken as destination file.
-l# denotes the language for messages sent by the program.
Supported are
5   English (US)
1   German

You can also call it from the Python-shell (it will query you for the filename):

>>> import CapToMusic
>>> doit()

You can also call it from the Python Idle window: Run - Run Module (F5)

FilenameWithoutExtension.capx will be translated to DestFile.xml and saved 
in the same directory. If a file of the same name is present, it will be 
overwritten.

--------------------------------------------------------

Version History:
Version 1.41 11/06/17
Correction for multiple bar rests in staves with more than one voice.

Version 1.40 11/14/16
Support for whole notes (semiquavers) with dots corrected.

Version 1.39 10/11/16
added support for French

Version 1.38 06/23/16
Correction for redundant tempo direction export avoiding.

Version 1.37  01/14/16
Multiple measure rests now exported via measure-style multiple-rest
- no longer via simple rest with longer duration.
Support for double measure repeat signs bound to barlines.
Corrections for template system staves that are lacking in an actual system.
Corrections for metrum changes at the staff end.
Character font support for page objects made more precise.

Version 1.36  11/06/15
Support for measure attribute for whole measure rests
Support for system right indent (for split coda systems)
Correction for endings tied to fixed barlines
Correction for endings text (now without dot)

Version 1.35  7/20/15
Correction for multiple measure rests.
Correction for clefs with octave shift.
Correction for music symbols in rich text fields.

Version 1.34  3/27/14
Further correction for tuplets change from version 1.32

Version 1.33 3/11/14
Correction for redundant tempo direction export avoiding.

Version 1.32 2/14/14
Support for time-modification normal-type (tuplets with differing note values),
and for tuplets starting on a rest.
Correction for key or time change before backward repeat signs.

Version 1.31 1/5/14
Tolerance for duration tuplet element without count.

Version 1.30 10/25/13
Correction for midi-channel if more than 16 channels needed.

Version 1.29 10/24/13
Correction for measure repeats.

Version 1.28 9/23/13
Redundant tempo direction export avoided.
Correction for beam end control in polyrhythmic music.

Version 1.27 7/4/13
Correction for graphics tied to barlines.
Better support for capella3-characters D.S. and D.C. in freeform texts.

Version 1.26 6/5/13
If more than one page objects exist, they are now all exported.

Version 1.25 4/25/13
Correction of the advertized MusicXML version from 1.1 to 2.0. Indeed MusicXML 2.0 features could be exported since version 0.18.

Version 1.24 4/17/13
Correction for endings in staves with more than one voice, support for
graphics tied to barlines.

Version 1.23 4/11/13
Support for percussion note heads and measure repeats

Version 1.22 3/20/13
Support for saves with only 1 line (percussion).

Version 1.21 11/8/12
Support for time signature longAllaBreve (4/2) included.

Version 1.20 6/4/12
Graphic objects now export their offsets from their anchor notes as relative-x,
not as default-x as before (this had been ignored in Finale import anyway).
Tempo attributes of systems, notes, or rests are now exported, too.

Version 1.19 3/2/12
If an error occurs during the first step of reading a capx file (parseString),
now the error message allows localization of the error position in the file.

Version 1.18 11/24/11
If the source file did not contain an instrumentNames element, the
conversion is no longer stopped.
In parts with more than one staves (e.g. piano) the voice numbering is
now controlled in a way, that the first voice in the lower staff has the
same "voice" number attribute in the whole part.
If endings brackets overlap in capella, they are now exported more
appropriately, as they cannot overlap in MusicXML.
If CapToMusic is started from capella, and an error occurs during conversion, 
and the error message contains characters like , the error message will
now display correctly.

Version 1.17 11/19/10
Brackets that were no endings led to export errors, if the system had a
hidden staff.

Version 1.16 11/08/10
Endings, Wedges, etc., which have both of their anchors attached to a single note object, do no longer cause export errors.
Foreign language support improved.

Version 1.15 03/29/09
Whole measure rests are now distinguished correctly from other rests.

Version 1.14 11/10/08
No more backup elements with duration 0 will be exported.
Scores with 7 sharps or flats are now supported (before only 6)
Non-ascii characters in instrument names are exported correctly, even if
they are to be written between the staff lines and there is no brace around
both staves.
Transposing instruments will be exported as transposing.
Signs for string instrument up-bow and down-bow are now exported.
Wedges with their end attached to the same note as the start will be exported,
too.

Version 1.13 02/03/08
Beam groups could be built over barlines, as well as over rests, key or
clef changes. This was ignored in some situations by Finale and Sibelius
import, so the score seemed ok. Now the export is corrected.
Barlines in conjunction with key changes are exported more precisely.
If there were key or clef changes on the first system, an additional, 
useless (but not harmful) print system-layout element was generated.

Version 1.12 01/28/08
For music with no time signature (senza-misura), Finale and Sibelius need
an artificial measure for each system. From now on, its closing barline
is invisible.
Starting at the second system, the left indent was wrong, now 
corrected.
If an accidental has been set only as a reminder (capella: "forced"), it
is now exported as well.

Version 1.11 09/14/07
Irregular divisions higher than 6 are exported correctly.
Chord symbols containing RichText exported better.
Clefs, time signatures, and keys before a line break corrected.
Double-sharp and double-flat corrected in some situations.
Normal sized notes without duration are not accepted by MusicXML, so
we export them as small.
Rests without duration are not accepted by MusicXML, so we suppress them.
Text bound to the page exported better in some situations.

Version 1.10 04/23/07
Metronome directions are now exported correctly in some situations that were
working wrong before.
Brackets (like 8va), which are voltas without numbers in capella, are now 
exported.
Some corrections with chord symbols.
Infinite measures are exported better in some situations.
MusicXML cue notes cannot have ties. This is taken into account now.
Rests with "vertical position" on "center of staff" are now exported correctly,
even if their clef is G with octave-change.
The element encoding-date now conforms to MusicXML specifications.
The call from Python (without capella and capella-scan) now conforms better 
to Python habits.

Version 1.09 03/12/07
A time sign at the end of a staff no longer leads to an empty measure insertion.
Paper format setup has no longer german words interspersed.

Version 1.08 02/12/07
Paper formats different from A4 are now supported via SetupC2M

Version 1.07 01/20/07
Changed declaration from <score-partwise> to <score-partwise version="1.1">,
because programs that only handle MusicXML version 1.1 files can get 
confused if this version attribute is missing.

Version 1.06 01/18/07
Error corrected in support for lacking staves of template system.

Version 1.05 12/22/06
Error corrected in export of barlines with repeat in both directions.
Support added for barlines and endings in such systems, that the first
staff of the template system is lacking.

Version 1.04 12/15/06
Error corrected in systems with different time signs in some staves, when
some voices are not complete.
Avoid redundant time attribute writing (Sibelius printed unwanted time signs 
at system ends in some situations)

Version 1.03 12/14/06
Parameter control by CapToMusic.opt corrected. Options are now really evaluated,
and recorded in the MusicXML file as <encoding-description>. SetupC2M dialogs
on command line now easier to understand.

Version 1.02 12/05/06
Rtf2TxtAndFont.py (a file contained in the ZIP-package) modified to support
minimal python environment

Version 1.02 12/05/06
Bug corrected concerning postgrace notes.
Finale import problem with senseless chord symbols fixed.

Version 1.01 12/04/06
On Windows systems, the settings are saved in a file CapToMusic.opt located
in the application data (HKCU\software\windows\CurrentVersion\explorer\Shell Folder\AppData) directory capella-software\CapToMusic instead of the
Windows registry. So no administrator privileges are necessary.

Version 1.0 12/04/06
Identical with 0.25

Version 0.25 12/03/06
An error concerning metrum changes within one system, and whole rests and 
notes, has been corrected
Command line support improved: Source and destination file name may be
distinct now, and there is a choice for the user interface language.
Error handling improved: In case of a conversion error which leads to
program termiation, the program will now report, at which place in the
score the error occurred.
A mechanism for persistent parameter control has been introduced by means 
of the new script SetupC2M.py. This script controls the parameters
globalExportToSibelius, globalFinaleDolet33 and globalChordCaseMatters.
For more information on the meaning of these parameters, see the comments
in the code. By this mechanism, CapToMusic can be optimized for special
needs without changing the code. The settings are stored in the Windows 
Registry. On non-windows systems, a file CapToMusic.opt is used.

Version 0.22, 0.23, 0.24
unpublished

Version 0.21 11/19/06
Whole notes in 12/8 time and others are now exported correctly.
Execution time reduced for systems with many staves.

Version 0.20 11/15/06
Supported user interface languages English and German
Export from capella now has file save dialog box

Version 0.19 11/12/06
Whole notes in 6/8 time are now exported correctly.
Some forgotten dialog boxes deactivated.
Exporting incomplete voices is less disturbed by invisible
rhythm irregularities
Endings with multiple numbers now exported correctly.

Version 0.18 11/11/06
Whole notes in 2/4 and 1/4 time are now exported correctly.
Grace notes and postgrace notes treated differently now.
In systems with different time signs in some staves like 
"Don Giovanni menuet", the "non-controlling" attribute is
supported. This is, though, not evaluated on import in Finale
nor in Sibelius.

Version 0.17 11/06/06
Invisible notes and rests are now exported as invisible
(Attention Sibelius users: Sibelius 4 does not support
invisibility. Please edit the source code and set
globalExportToSibelius = True. Then there will be a
forward-Element inserted instead of a invisible 
note).
Incomplete voices are completed ivisibly - this avoids
Sibelius import errors.
Whole notes/rests with dot now exported correctly.
Whole notes in 3/4 time are now exported correctly.

Version 0.16 9/07/06
Support for multiline text expressions for Finale Dolet 3.3 and newer (for older
Dolet versions, one text expression is generated for every line of text)

Version 0.15 9/04/06
Support for music without measures (senza-misura)

Version 0.14 8/18/06
Chord symbols now with support for bass notes after slash (C/G) and with
support for those capella transposable symbols, which are composed of groups
of simple text elements (to avoid rich text, which is memory inefficient in 
this context)

Version 0.13 8/7/06
Implicit time attributes no longer cause a change between "allaBreve" and
2/2 or between "C" and 4/4.
Chord symbols are now exported with position control. German and Italian 
(Solfeggio) chord base naming supported (Es, B, F, C, .., H, Fis; Mib, Sib,
Fa, Do, .., Si, Fa#; Me, Te, Fa, Do, .., Ti, Fi) (in Finale choose Chord -
Chord Style!)
Support for chords without duration at measure end.
Support for text fields with contained segno or coda improved.
Bugfix for a problem in Rtf2TextAndFont causing program termination.

Version 0.12 7/31/06
Metronome directions in parentheses now export the parentheses, too

Version 0.11 7/21/06
Dots after rests now exported graphically correct.
Measure numbering may start other than 1. Though, it is not possible to
export capella's correction of automatic measure numbering (which may
occur on any system break).
Bugfix for grace notes

Version 0.10 7/19/06
Implicit time directives now exported
Bugfix in beam handling

Version 0.9 7/17/06
Transposable symbols (chord symbols) are now exported. There are limitations
in german or italian chord symbol style.
Left indent of staff systems is supported more precisely.
Metronome directions are now exported.
Notes and rests with duration of more than one measure are now exported. This
does not work correctly, if the long rests are different for different voices.

Version 0.8, 6/19/06
Corrections in cyrillic and greek text export (If you use the new Recordare
Dolet V 3.2, these texts are shown correctly in Finale whithout the special
tricks mentioned for version 0.6 of this program)
Corrections in lyrics export (only visible if Recordare Dolet V 3.2 is used)
Corrections in export of credits
Corrections in fine positioning of segno and coda
Corrections in staff distance export


Version 0.7, 5/28/06
Support for scores with some empty staves in some systems
Support for cue and grace notes, trills, mordents and turns
Support for vertical position control for rests
Support for capella multiline text fields (used in chord fingerings)
Correction for slurs in multi voice parts
correction for beams in tuplets

Version 0.6, 4/27/06
Support for text in greek, cyrillic, east europe, baltic. Note: Finale requires that your system language is switched to the one to be displayed. You will also have to change the "script" value in the text font manually for each text and lyric!
Support for scores with systems such that some parts may be lacking (like Recordare's MozaVeilSample.xml).
part-abbreviation export now only if it is used.

Version 0.5, 4/13/06
First published version